Skip to content

Python: Support ternary comparisons in PatternMatchingComparator#6809

Merged
knutwannheden merged 1 commit intomainfrom
oddly-puffin
Feb 24, 2026
Merged

Python: Support ternary comparisons in PatternMatchingComparator#6809
knutwannheden merged 1 commit intomainfrom
oddly-puffin

Conversation

@knutwannheden
Copy link
Copy Markdown
Contributor

Summary

  • Add _compare_ternary method to PatternMatchingComparator to properly compare j.Ternary (conditional expression) nodes by recursively comparing condition, true_part, and false_part
  • Previously, ternary expressions fell through to the default case which returned True without deep comparison, causing incorrect matches

Test plan

  • New TestTernaryMatching tests: placeholder captures, concrete match, condition/true_part/false_part mismatches
  • All 42 existing comparator tests still pass

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Feb 24, 2026
@knutwannheden knutwannheden merged commit 15ebbf2 into main Feb 24, 2026
1 check passed
@knutwannheden knutwannheden deleted the oddly-puffin branch February 24, 2026 14:19
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant